package com.chushouya.common.constant;

import com.general.framework.core.enums.IEnum;
import com.general.framework.core.lang.Strings;

import java.util.Objects;

/**
 * 1number,2string,3number array,4string array
 */
public enum ValueTypeEnum implements IEnum<Integer> {

    value_string(1,  "string"),
    value_array( 2,  "array");

    private Integer value;

    private String desc;

    ValueTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer value() {
        return this.value;
    }

    @Override
    public String named() {
        return this.desc;
    }

    public static String getDesc(Integer value) {
        for (ValueTypeEnum thisEnum : ValueTypeEnum.values()) {
            if (Objects.equals(thisEnum.value, value)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }

    public static boolean isArray(Integer valueType) {
        return ValueTypeEnum.value_array.value().equals(valueType);
    }
}
